"! Info:
A basic robot class. Provides functionality to move and check sensors.
Examples:

"
Object subclass: Robot [
| speed |
<category: 'Library-Hardware'>
"! "
angle [
<getPosition 2>
]

"! Info:
Start the motors driving backwards.

Examples:
self back.
"
back [
System motionCommand: 0 value: (self encoderLeft + 1).
System motionCommand: 1 value: (self encoderRight + 1).
self motorLeft: speed negative Right: speed negated.
]

"! Info:
Drive a specified distance backwards.

Examples:
\"drive backwards for 1 second\"
self back: 1000.
\"drive backwards for 1/2 a second\"
self back: 500.
"
back: dist [
| s |
s := speed negated.
System motionCommand: 0 value: (self encoderLeft - (dist * 10)).
System motionCommand: 1 value: (self encoderRight - (dist * 10)).
self motorLeft: s Right: s.
[System inMotion] whileTrue: [ ].
self stop.  ]

"! Info:
Check if either bumper is pressed
Examples:

"
bumpEither [
^ self bumpLeft or: [ self bumpRight ].
]

"! Info:
Check if the left bumper is pressed.

Examples:
\"print a message if the left bumper is hit\"
self bumpLeft ifTrue: [
  'Hit left bumper' printNl.
].
"
bumpLeft [
^ System digitalRead: 0  ]

"! Info:
Check if the right bumper is pressed.

Examples:
\"print a message if the right bumper is hit\"
self bumpLeft ifTrue: [
  'Hit right bumper' printNl.
].
"
bumpRight [
^ System digitalRead: 1  ]

"! "
encoderLeft [
<getEncoder 0>
]

"! "
encoderRight [
<getEncoder 1>
]

"! Info:
Start the motors driving forwards.

Examples:
self fwd.
"
fwd [
System motionCommand: 0 value: (self encoderLeft - 1).
System motionCommand: 1 value: (self encoderRight - 1).
self motorLeft: speed Right: speed.  ]

"! Info:
Drive a specified distance forwards.
Examples:
self fwd: 1000. \"drive forwards for 1 second\"
self fwd: 500.  \"drive forwards for half a second\"
"
fwd: dist [
System motionCommand: 0 value: (self encoderLeft + (dist * 10)).
System motionCommand: 1 value: (self encoderRight + (dist * 10)).
self motorLeft: speed Right: speed.
self waitUntilStopped.
self stop.  ]

"! Info:
Turn left by a specified number of degrees.

Examples:

self left: 90.  \"Make a 90 degree left turn\"
self left: 360. \"Make a full 360 degree left turn\"
"
left: degrees [
System motionCommand: 0 value: (self encoderLeft - (degrees*10)).
System motionCommand: 1 value: (self encoderRight + (degrees*10)).
self motorLeft: speed negated Right: speed.
self waitUntilStopped.
self stop.
]

"! Info:
Read the left light sensor.
Examples:
self lightLeft printNl.
"
lightLeft [
^ System analogRead: 2  ]

"! Info:
Read the left light sensor.
Examples:
self lightRight printNl.
"
lightRight [
^ System analogRead: 3  ]

"! "
lineMiddle [
^ System digitalRead: 3
]

"! Info:
Set motor speeds to the specified values.
Examples:

"
motorLeft: left Right: right [
System setMotor: 0 velocity: left.
System setMotor: 1 velocity: right.  ]

"! Info:
Turn right by a specified number of degrees.
Examples:
self right: 90.  \"Make a 90 degree right turn\"
self right: 360. \"Make a full 360 degree right turn\"
"
right: degrees [
System motionCommand: 0 value: (self encoderLeft + (degrees*10)).
System motionCommand: 1 value: (self encoderRight - (degrees*10)).
self motorLeft: speed Right: speed negated.
self waitUntilStopped.
self stop.
]

"! "
say: text [
text printNl.
]

"! Info:
Wait for a specified number of milliseconds.
Examples:
self sleep: 500.
"
sleep: ms [
System sleep: ms  ]

"! "
speed: s [
speed := s.
]

"! Info:
Stop moving.
Examples:
self stop.
"
stop [
self motorLeft: 0 Right: 0.  ]

"! "
waitUntilStopped [
[System inMotion] whileTrue: [
	System sleep: 20.
].
]

"! "
x [
<getPosition 0>
]

"! "
x: x y: y [
<setPosition x y>
]

"! "
y [
<getPosition 1>
]

]

"! "
MetaObject subclass: MetaRobot [
<category: 'Library-Hardware'>
"! "
new [
| ret |
ret := super new.
ret speed: 128.
^ ret.
]

]

